﻿@model HdipCricketClub.ViewModels.ScorecardEnterScoresViewModel

@{
    ViewBag.Title = "InputScorecardScoresBattedSecond";
}

<h2>Input Scorecard Scores Batted Second</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (@Html.BeginForm("InputScorecardScoresBattedSecond", "Scorecard", FormMethod.Post))
{
    @Html.ValidationSummary(false)
    <fieldset>
    <legend>Fixture:</legend>
    <br />
    @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName) @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.name)
    vs @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name) @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.team_name)
    <br />
    on @Html.DisplayFor(ModelItem => Model.ScorecardFixture.date)
    @Html.HiddenFor(ModelItem => Model.ScorecardFixture.fixture_id)
    <br /><br />
    @ViewBag.Message
    @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.result_id)
    @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.won_toss)
    @Html.HiddenFor(ModelItem => Model.ScorecardHeaderDetail.batted_first)
    <br />
    </fieldset>
    
    <fieldset>
    <legend>Innings of @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Opponent.club_name)</legend>
    <br />
    <table>
        <tr>
            <th></th>
            <th>
                Name:
            </th>
            <th>
                How Out:
            </th>
            <th>
                Fielder:
            </th>
            <th>
                Bowler:
            </th>
            <th>
                Runs:
            </th>
        </tr>
    @foreach (var item in Model.OpponentBatsmen)
    {
        <tr>
                @Html.HiddenFor(modelItem => item.op_fixture_id)
                @Html.HiddenFor(modelItem => item.op_batsman_number)
                @Html.HiddenFor(modelItem => item.op_player_name)
            <td>
                @Html.DisplayFor(modelItem => item.op_batsman_number)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.op_player_name)
            </td>
            <td>
                @Html.DropDownList("op_dismissal_id", string.Empty)

            </td>
            <td>
                @Html.DropDownList("fielder_id", string.Empty)
            </td>
            <td>
                @Html.DropDownList("bowler_id", string.Empty)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.op_batting_runs)
            </td>
        </tr>
    } 
    <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Byes:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.byes)
                @Html.ValidationMessageFor(ModelItem => Model.OpponentOtherDetail.byes)
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Leg Byes:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.leg_byes)
                @Html.ValidationMessageFor(ModelItem => Model.OpponentOtherDetail.leg_byes)
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Wides:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.wides)
                @Html.ValidationMessageFor(ModelItem => Model.OpponentOtherDetail.wides)

            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                No Balls:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.OpponentOtherDetail.no_balls)
                @Html.ValidationMessageFor(ModelItem => Model.OpponentOtherDetail.no_balls)
            </td>
        </tr>
    </table>
    <br />
    <table>
        <tr>
            <th></th>
            <th>
                Name:
            </th>
            <th>
                Overs:
            </th>
            <th>
                Maidens:
            </th>
            <th>
                Runs:
            </th>
            <th>
                Wickets:
            </th>
        </tr>
    @foreach (var item in Model.ClubBowlers)
    {
        <tr>
                @Html.HiddenFor(modelItem => item.fixture_id)
                @Html.HiddenFor(modelItem => item.player_id)
                @Html.HiddenFor(modelItem => item.bowler_number)
            <td>
                @Html.DisplayFor(modelItem => item.bowler_number)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Member.InitialAndLastName)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.overs)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.maidens)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.bowling_runs)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.wickets)
            </td>
        </tr>
    }
    </table>
    </fieldset>
    <fieldset>
    <legend>Innings of @Html.DisplayFor(ModelItem => Model.ScorecardFixture.Team.Club.ShortName)</legend>
    <br />
    <table>
        <tr>
            <th></th>
            <th>
                Name:
            </th>
            <th>
                How Out:
            </th>
            <th>
                Fielder:
            </th>
            <th>
                Bowler:
            </th>
            <th>
                Runs:
            </th>
        </tr>
    @foreach (var item in Model.ClubBatsmen)
    {
        <tr>
                @Html.HiddenFor(modelItem => item.fixture_id)
                @Html.HiddenFor(modelItem => item.player_id)
                @Html.HiddenFor(modelItem => item.batsman_number)
            <td>
                @Html.DisplayFor(modelItem => item.batsman_number)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Member.InitialAndLastName)
            </td>
            <td>
                @Html.DropDownList("dismissal_id", string.Empty)
                @Html.ValidationMessageFor(modelItem => item.how_out)
            </td>
            <td>
                @Html.DropDownList("op_fielder_name", string.Empty)
            </td>
            <td>
                @Html.DropDownList("op_bowler_name", string.Empty)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.batting_runs)
                @Html.ValidationMessageFor(modelItem => item.batting_runs)
            </td>
        </tr>
    } 
    <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Byes:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.ClubOtherDetail.byes)
                @Html.ValidationMessageFor(ModelItem => Model.ClubOtherDetail.byes)
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Leg Byes:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.ClubOtherDetail.leg_byes)
                @Html.ValidationMessageFor(ModelItem => Model.ClubOtherDetail.leg_byes)
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                Wides:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.ClubOtherDetail.wides)
                @Html.ValidationMessageFor(ModelItem => Model.ClubOtherDetail.wides)
            </td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td>
                No Balls:
            </td>
            <td>
                @Html.EditorFor(ModelItem => Model.ClubOtherDetail.no_balls)
                @Html.ValidationMessageFor(ModelItem => Model.ClubOtherDetail.no_balls)
            </td>
        </tr>
    </table>
    <br />
    <table>
        <tr>
            <th></th>
            <th>
                Name:
            </th>
            <th>
                Overs:
            </th>
            <th>
                Maidens:
            </th>
            <th>
                Runs:
            </th>
            <th>
                Wickets:
            </th>
        </tr>
    @foreach (var item in Model.OpponentBowlers)
    {
        <tr>    
                @Html.HiddenFor(modelItem => item.op_fixture_id)
                @Html.HiddenFor(modelItem => item.op_batsman_number)
                @Html.HiddenFor(modelItem => item.op_bowler_number)
                @Html.HiddenFor(modelItem => item.op_player_name)
            <td>
                @Html.DisplayFor(modelItem => item.op_bowler_number)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.op_player_name)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.op_overs)
                @Html.ValidationMessageFor(modelItem => item.op_overs)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.op_maidens)
                @Html.ValidationMessageFor(modelItem => item.op_maidens)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.op_bowling_runs)
                @Html.ValidationMessageFor(modelItem => item.op_bowling_runs)
            </td>
            <td>
                @Html.EditorFor(modelItem => item.op_wickets)
                @Html.ValidationMessageFor(modelItem => item.op_wickets)
            </td>
        </tr>
    }
    </table>
    </fieldset>
    <br />
    <p>
        <input type="submit" value="Enter" />
    </p>    
}